package dto;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import util.general.*;
import util.i3enum.*;

/**
 * 
 * @author ThaiBaoDoan
 *  base of File 
 */
public class TotalFileBase {
	
protected	String _stdFileName;
protected File  _file;
protected FileType _fileType;
protected long  _lSize;
protected String _stdLastModified;

public String get_stdLastModified() {
	return _stdLastModified;
}

public void set_stdLastModified(String _stdLastModified) {
	this._stdLastModified = _stdLastModified;
}

public String get_stdFileName() {
	return _stdFileName;
}

public void set_stdFileName(String _stdFileName) {
	this._stdFileName = _stdFileName;
}
public FileType get_fileType() {
	return _fileType;
}

public void set_fileType(FileType _fileType) {
	this._fileType = _fileType;
}
public long get_lSize() {
	return _lSize;
}

public void set_lSize(long _lSize) {
	this._lSize = _lSize;
}

public File get_file() {
	return _file;
}

public void set_file(File _file) {
	this._file = _file;
}

public static List<TotalFileBase> GetAllFile(String path)
{
	List<TotalFileBase> _total = new ArrayList<TotalFileBase>();
	File parent = new File(path);
	String listFile[] = parent.list();
	if(listFile == null)
		return null;
     for (int i = 0; i < listFile.length; i++) {
    	 String DirTemp = path + "\\" + listFile[i].toString();
    	 File FileTemp = new File(DirTemp);
    	 if(FileTemp.isHidden() || config_general.IsSystemFile(DirTemp))
    		  continue;
    	 TotalFileBase item = new TotalFileBase();
    	 item.set_file(FileTemp); //set file core
    	 item.set_stdFileName(listFile[i].toString());
         
         
         SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm"); 
         item.set_stdLastModified(sdf.format(FileTemp.lastModified())) ; 
         if (FileTemp.isDirectory()) {
        	 item.set_lSize(-1);
         } else {

        	 item.set_lSize(FileTemp.length());
         }
         _total.add(item);
     }
	return _total;
}


}
